<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition template="/WEB-INF/layout.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <h:form id="formLista">
            <p:panel header="Lista de Treinos">

                <p:dataTable id="treinos" var="treino" style="width:100%;"
                             value="#{treinoController.treinoDM}" 
                             rowKey="#{treino.idTreino}"
                             selection="#{treinoController.treinoSelecionado}"
                             selectionMode="single">
                    <p:ajax event="rowSelect" listener="#{treinoController.onRowSelectTreino}" />

                    <p:column headerText="Aluno">
                        #{treinoController.alunoSelecionado.nome}
                    </p:column>

                    <p:column headerText="Data da Última atualização">
                        #{treino.dataInicio}
                    </p:column>

                    <p:column headerText="Objetivo">
                        #{treino.objetivo}
                    </p:column> 
                </p:dataTable>

                <p:commandButton value="Alterar" action="#{treinoController.alterarTreino}" ajax="false"/>
                <p:spacer width="10" height="50"/>
                <p:commandButton value="Visualizar" action="#{treinoController.visualizarTreino}" ajax="false"/>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>